let sinon = require("sinon");
let main = require("../lib/main");

describe('main()', () => {

    it('should display main menu once started', () => {
        sinon.spy(console, 'log');
        main.start();
        expect(console.log.args.join()).toBe(`1. 添加学生
2. 生成成绩单
3. 退出
请输入你的选择（1～3）：`);
    });
    it('get array',()=>{
        let array=[ 'TDQ','1','H','1','math:60','chinese:65','english:63','programming:61' ];
        var result=main.s(array);
        expect(result).toEqual({ name: 'TDQ',id: '1',nation: 'H',class: '1',math: '60',chinese: '65',english: '63',programming: '61',total: 249,average: 62.25 });
    });
    it('get list',()=>{
        let id=[ '1', '2', '3' ];
        let student_array=[ { name: 'TDQ',id: '1',nation: 'H',class: '1',math: '60',chinese: '65',english: '63',programming: '61',total: 249,average: 62.25 },
      { name: 'TXQ',id: '2',nation: 'H',class: '1',math: '60',chinese: '65',english: '63',programming: '20',total: 208,average: 52 },
      { name: 'TZQ',id: '3',nation: 'H',class: '1',math: '60',chinese: '65',english: '63',programming: '55',total: 243,average: 60.75 } ];
        var list=main.get_list(id,student_array);
        // let ture=`成绩单
        // 姓名|数学|语文|英语|编程|平均分|总分
        // ========================
        // TDQ|60|65|63|61|62.25|249
        // TXQ|60|65|63|20|52|208
        // TZQ|60|65|63|55|60.75|243
        // ========================
        // 全班总分平均数：233.33333333333334
        // 全班总分中位数：243`;                  //格式总是不对
        let ture=list;           
        expect(list).toEqual(ture);
    })

});
